package com.x.Part3_inherit;

/**
 * ClassName: inherit1
 * Package: IntelliJ IDEA
 * Description:
 * Written by HanXu
 * Create 2023/9/27 20:51
 */


public class inherit1 {
    public static void main(String[] args) {
        Student1 s1 = new Student1();
        s1.setName("Mack");
        System.out.println(s1.tell());
    }
}

class Person1 {
    //private String name;
    //属性设置为private，子类不可访问，故设置为protected
    protected String name;
    //private int age;
    protected int age;

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getAge() {
        return age;
    }
    public void setAge(int age) {
        this.age = age;
    }
}

class Student1 extends Person1{
    private int score;

    public int getScore() {
        return score;
    }
    public void setScore(int score) {
        this.score = score;
    }
    public String tell(){
        return "My name is " + name;
    }
}
